<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@page import="com.tjsinfo.tjsoa.system.vo.User"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>粮油集团办公自动化协作平台</title>
    <meta http-equiv="x-ua-compatible" content="ie=7" />
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<link href="<%=basePath%>style/txlz7.css" rel="stylesheet" type="text/css" id="txlz7"/>
	<link rel="stylesheet" type="text/css" href="<%=basePath%>ajaxFramework/ext-2.1/resources/css/ext-all.css" />
	<script type="text/javascript" src="<%=basePath%>ajaxFramework/ext-2.1/adapter/ext/ext-base.js"></script>
	<script type="text/javascript" src="<%=basePath%>ajaxFramework/ext-2.1/ext-all-debug.js"></script>
	
	<script type="text/javascript" src="<%=basePath %>ajaxFramework/ext-2.1/adapter/ext/ext-base.js"></script>
   	<script type="text/javascript" src="<%=basePath %>ajaxFramework/ext-2.1/ext-all.js"></script>
	<script type="text/javascript" src="<%=basePath %>ajaxFramework/ext-2.1/source/locale/ext-lang-zh_CN.js"></script>
	
	<style type="text/css">
			td {
				font:12px/170% "宋体", "新宋体", "黑体"; color:#000
			}
			th {
				font:12px/170% "宋体", "新宋体", "黑体"; color:#000;
				text-align: center;
			}
	</style>
	<style>
		 #divgroup {width:100%;height:100%;overflow:hidden;}
         .trBgColor { background-color:#A4D7E8; cursor: hand;}
         .trGroupColor { background-color:#C3EBF9; cursor: hand;}
         .trHiddivColor { background-color:#c3ebf9; cursor: hand;}
		#container {
		    width:600px;
		    height:300px;
		    border:3px solid #c3daf9;
		}
		
		.calendar {
		    background-image:url(<%=basePath%>images/icon_64.gif) !important;
		}
		
		.xinjianqian {
		    background-image: url(<%=basePath%>images/s_01.gif) !important;
		}
		.xiugaiqian {
		    background-image: url(<%=basePath%>images/s_02.gif) !important;
		}
		.shanchuqian {
		    background-image: url(<%=basePath%>images/s_03.gif) !important;
		}
		.daohang {
		    background-image: url(<%=basePath%>images/ju.gif) !important;
		}
		
		.menu-title{
		    background: #ebeadb url(<%=basePath%>addresslist/images/m_icon07.gif) repeat-x;
		    border-bottom:1px solid #99bbe8;
		    color:#15428b;
		    font:bold 10px tahoma,arial,verdana,sans-serif;
		    display:block;
		    padding:3px;
		}
         
         .hiddiv {
			display: none;
			position: absolute;
			top: 6%;
			left: 0%;
			width: 84;;
			height: 72;
			border: 1px solid #FFF;
			border-bottom:none;
			z-index:1002;
			overflow: auto;
		}
		.insertGroup {
			display: none;
			position: absolute;
			border: 1px solid #FFF;
			border-bottom:none;
			z-index:1002;
			overflow: auto;
		}
		.updateGroupIndexDiv {
			display: none;
			position: absolute;
			border: 1px solid #FFF;
			border-bottom:none;
			z-index:1002;
			overflow: auto;
		}
		.deleteGroupIndexDiv {
			display: none;
			position: absolute;
			border: 1px solid #FFF;
			border-bottom:none;
			z-index:1002;
			overflow: auto;
		}
		.black_overlays{
			display: none;
			position: absolute;
			top: 0%;
			left: 0%;
			width: 100%;
			height: 100%;
			background-color: #C1EBFC;
			z-index:1002;
			-moz-opacity: 0.8;
			opacity:.80;
			filter: alpha(opacity=30);
		}
		.cha {
			padding-top: 0px
		}
   </style>
    <link href="<%=basePath %>ajaxFramework/ext-2.1/resources/css/ext-all.css" rel="stylesheet" type="text/css" />
	<script type="text/javascript" src="<%=basePath %>ajaxFramework/ext-2.1/adapter/ext/ext-base.js"></script>
    <script type="text/javascript" src="<%=basePath %>ajaxFramework/ext-2.1/ext-all-debug.js"></script>
    <script type="text/javascript" src="<%=basePath %>ajaxFramework/ext-2.1/source/locale/ext-lang-zh_CN.js"></script>
    
	<script type='text/javascript' src='<%=basePath%>dwr/interface/AddressListGroupBo.js'></script>
	<script type='text/javascript' src='<%=basePath%>dwr/interface/AddressListUserBo.js'></script>
	<script type='text/javascript' src='<%=basePath%>dwr/interface/AddressListUserPageBo.js'></script>
	<script type='text/javascript' src="<%=basePath%>dwr/engine.js"></script>
	<script type='text/javascript' src="<%=basePath%>dwr/util.js"></script>
	<%
		User user = (User)session.getAttribute("user");
		String group_id = (String)request.getAttribute("group_id");
		if(group_id==null)group_id="";
		String user_page = (String)request.getAttribute("user_page");
		String user_id = (String)request.getAttribute("user_id");
		if(user_id==null)user_id="";
		String first = (String)request.getAttribute("first");
		String moduleType = (String)request.getAttribute("moduleType");
		String permission = user.getPermission();
	 %>
	<script type="text/javascript">
		window.onload = function(){
		windowonload();
			var menu = new Ext.menu.Menu({
		        id: 'mainMenu',
		        width:90,
		        items: [
		            {
		                text: '新增组',
		            	iconCls: 'xinjianqian',  // <-- icon
		                handler: function(){
							xianshiInsertGroup();
						}
		            },
		            {
		                text: '修改组',
		                iconCls: 'xiugaiqian',  // <-- icon
			        	handler: function(){
							xianshiUpdateGroup();
						}
		            },
		            {
		                text: '删除组',
		                iconCls: 'shanchuqian',  // <-- icon
		                handler: function(){
							xianshiDeleteGroup();
						}
		            }
		        ]
		    });
			var tb = new Ext.Toolbar(
				{
					height:25
				}
			);
		
		    tb.render('menu');
			tb.add(
			<%if((permission.contains(",12,") && moduleType.equals("0")) || moduleType.equals("1")){%>
			{
		            text:'组编辑',
		            iconCls: 'daohang',
		            menu: menu  // assign menu by instance
		        
		    }
		    <%}
		    if(moduleType.equals("1")){%>
		    ,
		    {
		            text:'复制',
		            iconCls: 'daohang',
		        	handler: function(){
						window.location.href="";
						location.href="<%=basePath %>tjsinfo/tjsoa/addresslist/toCopyAddressListUser.do?first=shi&moduleType=<%=moduleType %>&type=copy";
					}
		    },
		    {
		            text:'移动',
		            iconCls: 'daohang',
		        	handler: function(){
						window.location.href="";
						location.href="<%=basePath %>tjsinfo/tjsoa/addresslist/toCopyAddressListUser.do?first=shi&moduleType=<%=moduleType %>&type=move";
					}
		    }
		    <%}
			  if((permission.contains(",12,") && moduleType.equals("0")) || moduleType.equals("1")){%>
		    ,
		    {
		            text:'新建联系人',
		            iconCls: 'daohang',
		        	handler: function(){
						submitAddListUser();
					}
		    }
		   <% }	%>
		    );
		
		}
		var group_id = '<%=group_id %>';//当前选中组
		var intpage = <%=user_page %>;//联系人当前页
		var first = '<%=first %>';//当前页面状态，是否第一次进入.insert-新增返回、delete-删除返回、updateorselect-更新或查看返回
		var user_id = '<%=user_id %>';//当前选中的联系人ID
		var pagenum = '16';//当前联系人每页条数
		if(intpage == '' || intpage == null){intpage = 1}
		
		function windowonload(){//页面加载
			//显示加载阴影
			document.getElementById("jiazai").style.top = document.body.clientHeight/3;
			document.getElementById("jiazai").style.left = document.body.clientWidth/3;
			document.getElementById("jiazai").style.display = "block";
			document.getElementById("blackdiv").style.display = "block";
			
			document.getElementById("divgroup").style.height = document.body.clientHeight-80;
			document.getElementById("tdindex").style.height = document.body.clientHeight-90;
			document.getElementById("tdindex").style.width = document.body.clientWidth-152;
			document.getElementById("divindex").style.width = document.body.clientWidth-151;
			document.getElementById("divindex").style.height = document.body.clientHeight-50;
			document.getElementById("conren").style.height = document.body.clientHeight-50;
			if(first == "shi"){//如果页面第一次加载，则返回结果显示第一个联系人组中的联系人信息
				AddressListUserPageBo.getFirstPage(<%=user.getUser_id() %>,<%=moduleType %>,pagenum,ListUser);
			}else if(first == "insert"){//如果页面新增联系人返回
				AddressListUserPageBo.getLastPage(group_id,<%=moduleType %>,pagenum,ListUser);//联系人列表：显示所新增组联系人信息的最后一页
				AddressListGroupBo.getGroup(<%=user.getUser_id() %>,<%=moduleType %>,Group);//显示组信息
			}else{//页面更新或查看联系人
				AddressListUserPageBo.getGotoPage(group_id,intpage,<%=moduleType %>,pagenum,ListUser);//联系人列表：显示所查看、更新联系人所在页
				AddressListGroupBo.getGroup(<%=user.getUser_id() %>,<%=moduleType %>,Group);//显示组信息
			}
		}
		
		var groupNum = 0;//组的数量
		var fu = null;//组的返回集合.
		function Group(fuzhi){
			var divgroup = document.getElementById("divgroup");//组所在的层
			fu = fuzhi;
			groupNum = fu.length/3;
			var liebiaoGroup = '<table id="grouptable" border="0" width="129px;" cellspacing="0" cellpadding="0">';
			var i = 0;
			for(var a=0;a<fu.length;a=a+3){//fu[a]--组ID，fu[a+1],组排序--组名称.
				if(fu[a] == group_id){//当此组为当前选中组ID
					document.addListUser.group_id.value = fu[a];//此时新增联系人时，所在组为第一个
					//class=\"trGroupColor\"，此组变色、粗体
					liebiaoGroup += '<tr id="group'+i+'" class=\"trGroupColor\" onclick="GroupListUser(\''+fu[a]+'\')" onmouseup=\"ClickGroup('+i+');\"><td width="23px" height="24px" align="center"><img src="<%=basePath%>images/conicon.gif"/></td><td height="24px" valign="middle" style=\"font-weight: bold\">';
					if(fu[a+1].length>8){
						liebiaoGroup += '<a id=\"groupA'+i+'\" title=\"'+fu[a+1]+'\">'+fu[a+1].substring(0,8)+'</a></td></tr>';
					}else{
						liebiaoGroup += '<a id=\"groupA'+i+'\">'+fu[a+1]+'</a></td></tr>';
					}
				}else{
					//其余组onmouseover、onmouseout,鼠标悬停变色
					if(fu[a+1].length>8){
						liebiaoGroup += '<tr id="group'+i+'" onmouseover=\'this.className=\"trGroupColor\"\' onmouseout=\'this.className=\"\"\' onclick="GroupListUser(\''+fu[a]+'\')" onmouseup=\"ClickGroup('+i+');\"><td width="23px" height="24px" align="center"><img src="<%=basePath%>images/conicon.gif"/></td><td height="24px" valign="middle"><a id=\"groupA'+i+'\" title=\"'+fu[a+1]+'\">'+fu[a+1].substring(0,8)+'</a></td></tr>';
					}else{
						liebiaoGroup += '<tr id="group'+i+'" onmouseover=\'this.className=\"trGroupColor\"\' onmouseout=\'this.className=\"\"\' onclick="GroupListUser(\''+fu[a]+'\')" onmouseup=\"ClickGroup('+i+');\"><td width="23px" height="24px" align="center"><img src="<%=basePath%>images/conicon.gif"/></td><td height="24px" valign="middle"><a id=\"groupA'+i+'\">'+fu[a+1]+'</a></td></tr>';
					}
				}
				i++;
			}
			if(fu.length>30){//当超过15个组时，出现上下滚动条
				document.getElementById("zushang").style.display = "block";
				document.getElementById("zuxia").style.display = "block";
				document.getElementById("divgroup").style.height = document.body.clientHeight-110;
			}else{//小于15个组，则隐去上下滚动条
				document.getElementById("zushang").style.display = "none";
				document.getElementById("zuxia").style.display = "none";
			}
			liebiaoGroup += '</table>';
			divgroup.innerHTML= liebiaoGroup;
		}
        
        var groupA = -1;//上一次选中的组ID
        function ClickGroup(i){//点击组事件
			if(groupA!=-1)//如果已点击过组
			document.getElementById("group"+groupA).onmouseout = function(){this.className=''};//为上次选中的组添加鼠标移开，去除变色、粗体效果
        	for(var a = 0 ; a<groupNum;a++ ){//循环组
				var b = document.getElementById("group"+a);//组tr的ID
				var c = document.getElementById("groupA"+a);//组名称的ID
				if(a == i){//如果为当前选中组
					b.className="trGroupColor";//tr变色
					c.style.fontWeight="bold";//名称粗体
					b.onmouseout = null;//鼠标移开后，颜色不变。原onmouseout=\'this.className=\"\"\'
					groupA = a;//记录组ID
				}else{//其余未选中组
					b.className='';//tr取消变色
					c.style.fontWeight="100";//字体恢复
				}
			}
        }
        
		function init(page){//记录当前页数，并跳转至该页
			intpage=page;
			AddressListUserPageBo.getGotoPage(group_id,intpage,<%=moduleType %>,pagenum,ListUser);
		}
		
		function ListUser(addressListUser){//联系人信息返回函数
			if(first == "shi"){//如页面第一次加载
				AddressListUserPageBo.getGroup(getGroup_id);//取得第一个组ID，并生成组列表
				first = "fou";
			}
			var divindex = document.getElementById("divindex");
			var liebiaoUser = '<table class="p_06" width=\"100%\" border=\"0\" cellspacing=\"0\"><tr><th width=\"3%\">&nbsp;</th><th width=\"8%\">姓名</th><th width=\"12%\">手机</th><th width=\"34%\">单位</th><th width=\"16%\">部门</th><th width=\"15%\">单位电话</th><th width=\"14%\">操作</th></tr>';
			<%
			if(!permission.contains(",12,") && moduleType.equals("0")){//当为公共通讯录时，如果没有12-公共通讯录管理，则无操作列
			%>
			liebiaoUser = '<table class="p_06" width=\"100%\" border=\"0\" cellspacing=\"0\"><tr><th width=\"3%\">&nbsp;</th><th width=\"8%\">姓名</th><th width=\"12%\">手机</th><th width=\"34%\">单位</th><th width=\"16%\">部门</th><th width=\"15%\">单位电话</th></tr>';
			<%
			}
			%>
			
			if(addressListUser.length != 0){//如果此页联系人信息不为空
			for(var i=0;i<addressListUser.length;i++){
				var id = addressListUser[i].id;
				var name = retrunString(addressListUser[i].userName,4,4);
				var name1 = addressListUser[i].userName;
				
				var mobile = addressListUser[i].mobile;if(mobile==null || mobile == '')mobile='&nbsp;'; else mobile = retrunString(mobile,11,11);
				var mobile1 = addressListUser[i].mobile;if(mobile1==null || mobile1 == '')mobile1='';
				
				var company = addressListUser[i].company;if(company==null || company == '')company='&nbsp;';else company = retrunString(company,24,18);
				var company1 = addressListUser[i].company;if(company1==null || company1 == '')company1='';
				
				var sector = addressListUser[i].sector;if(sector==null || sector == '')sector='&nbsp;';else sector = retrunString(sector,11,8);
				var sector1 = addressListUser[i].sector;if(sector1==null || sector1 == '')sector1='';
				
				var companyPhone = addressListUser[i].companyPhone;if(companyPhone==null || companyPhone == '')companyPhone='&nbsp;';else companyPhone = retrunString(companyPhone,13,13);
				var companyPhone1 = addressListUser[i].companyPhone;if(companyPhone1==null || companyPhone1 == '')companyPhone='';
				
				var xitong = addressListUser[i].userId;//如果同步，则取出其TjsUserID
				if(user_id != null && user_id != '' && user_id == addressListUser[i].id){//如当前为选中联系人,变色class=\"trBgColor\"
					if(xitong==null || xitong == ''){//如无同步
						liebiaoUser += '<tr class=\"trBgColor\"><td>&nbsp;</td>';
					}else{//如此联系人已被同步
						liebiaoUser += '<tr class=\"trBgColor\"><td><img src=\"<%=basePath%>images/xr.gif\" title="\正在同步的系统用户\"/></td>';
					}
					liebiaoUser += '<td><a href="<%=basePath %>tjsinfo/tjsoa/addresslist/toAddressListUser.do?type=select&user_id='+id+'&intpage='+intpage+'&moduleType=<%=moduleType %>" title=\"'+name1+'\">'+name+'</a></td><td><a title=\"'+mobile1+'\">'+mobile+'</td><td class=\"left_txt\"><a title=\"'+company1+'\">'+company+'</a></td><td><a title=\"'+sector1+'\">'+sector+'</a></td><td><a title=\"'+companyPhone1+'\">'+companyPhone+'</a></td>';
				}else{//其余未被选中联系人
					if(xitong==null || xitong == ''){//如无同步
						liebiaoUser += '<tr onmouseover=\'this.className=\"trBgColor\"\' onmouseout=\'this.className=\"\"\'><td>&nbsp;</td>';
					}else{//如此联系人已被同步
						liebiaoUser += '<tr onmouseover=\'this.className=\"trBgColor\"\' onmouseout=\'this.className=\"\"\'><td><img src=\"<%=basePath%>images/xr.gif\" title="\正在同步的系统用户\"/></td>';
					}
					liebiaoUser += '<td><a href="<%=basePath %>tjsinfo/tjsoa/addresslist/toAddressListUser.do?type=select&user_id='+id+'&intpage='+intpage+'&moduleType=<%=moduleType %>" title=\"'+name1+'\">'+name+'</a></td><td><a title=\"'+mobile1+'\">'+mobile+'</a></td><td class=\"left_txt\"><a title=\"'+company1+'\">'+company+'</a></td><td><a title=\"'+sector1+'\">'+sector+'</a></td><td><a title=\"'+companyPhone1+'\">'+companyPhone+'</a></td>';
				}
				<%
			if((permission.contains(",12,") && moduleType.equals("0")) || moduleType.equals("1")){//当为公共通讯录且有12-公共通讯录管理，或私人通讯录。联系人列添加操作列
			%>
			liebiaoUser += '<td valign="bottom"><a href="<%=basePath %>tjsinfo/tjsoa/addresslist/toAddressListUser.do?type=update&user_id='+id+'&intpage='+intpage+'&moduleType=<%=moduleType %>">修改</a> <a>\|</a> <a href="javaScript:deleteListUser(\''+id+'\');">删除</a></td></tr>';
			<%
			}
			%>
			}
			
			liebiaoUser += '<tr align=\"center\"><td colspan="7"><div class="page">';//分页
			AddressListUserPageBo.getPagecount({
			callback:function(pagecount) {
				//下拉框
			
			if(first == 'delete' && intpage == pagecount+1){//如果为删除返回，删除所在页最后一条联系人信息，则当前页数=后台重新页数+1
				intpage = pagecount;
				first = null;
			}
             var select="<select name=\"sel\">";
             for(var i=0;i<pagecount;i++){
                if((i+1)==intpage)
              select+="<option value=\""+(i+1)+"\" selected>"+(i+1)+"</option>";
              else
              select+="<option value=\""+(i+1)+"\">"+(i+1)+"</option>";              
             }
             select+="</select>";
             
             //链接条
             var linkstr="";
             if(intpage>pagecount)intpage=pagecount;
             
             if(intpage>1){
                linkstr+="&nbsp;&nbsp;<a href=\"javascript:init("+(Number(intpage)-1)+")\">上一页</a>";
             }
             if(intpage<pagecount){
                linkstr+="&nbsp;&nbsp;<a href=\"javascript:init("+(Number(intpage)+1)+")\">下一页</a>";
             }
             
             //按钮
             var btn="<input type='button' value='转到' onclick='init(sel.value)'/>";
             
             //  第XXX页/共XXX页
             var mix="<a>共"+pagecount+"页,当前为第"+intpage+"页</a>";
             
             divindex.innerHTML=liebiaoUser+mix+linkstr+'		'+select+'			'+btn;
             divindex.innerHTML+="</div></td></tr></table></form>";
			}
		});
			document.getElementById("jiazai").style.display = "none";//去除加载效果
			document.getElementById("blackdiv").style.display = "none";//去除加载效果
		}else{//当此页无联系人信息
			if(first == 'delete'){//如果为删除返回，删除所在页最后一条联系人信息
				AddressListUserPageBo.getLastPage(group_id,<%=moduleType %>,pagenum,ListUser);//重新返回当前组最后一页
				first = null;
			}
			liebiaoUser += '</table>';
		}
			divindex.innerHTML= liebiaoUser;
			document.getElementById("jiazai").style.display = "none";
			document.getElementById("blackdiv").style.display = "none";
			huifu();
		}
		
		function getGroup_id(Group_id){//重新生成组列表，并选中Group_id
			if(Group_id!=''){
				group_id = Group_id;
			}
			AddressListGroupBo.getGroup(<%=user.getUser_id() %>,<%=moduleType %>,Group);
		}
		
		function GroupListUser(groupid){//根据组ID，联系人列表显示相应联系人信息
			group_id = groupid;
			user_id = '';
			intpage = 1;
			document.addListUser.group_id.value = groupid;
			AddressListUserPageBo.getGotoPage(groupid,1,<%=moduleType %>,pagenum,ListUser);
		}
		
		function getXY(Obj) {//获取Obj的屏幕所在坐标，X-横向，Y-纵向
			var sumTop = 0, sumLeft = 0;
			while(Obj != document.body){
			sumLeft += Obj.offsetLeft;sumTop += Obj.offsetTop;Obj = Obj.offsetParent;
			} 
			return {x:sumLeft, y:sumTop};
		} 
		
		function xianshiInsertGroup(){//显示新增组层
			document.getElementById("insertGroup").style.top = document.body.clientHeight/4;
			document.getElementById("insertGroup").style.left = document.body.clientWidth/5;
			document.getElementById("insertGroupName").value = '';
			document.getElementById("insertGroup").style.display = "block";
			document.getElementById("blackdiv").style.display = "block";
		}
		
		function xiaoshiInsertGroup(){//消失新增组层
			document.getElementById("insertGroup").style.display = "none";
			document.getElementById("blackdiv").style.display = "none";
		}
		
		function insertGroup(){//点击新增组确定按钮
			var groupName = document.getElementById("insertGroupName").value;
			var groupNo = document.getElementById("insertGroupNo").value;
			var i = yanzhenggroupName(groupName);
			if(isNaN(groupNo) || groupNo==''){
				alert('排序请输入整数');
			}else{
				if(i != 'error'){
					AddressListGroupBo.insertGroup(groupName,<%=user.getUser_id() %>,<%=moduleType %>,groupNo,returnGroupCaoZuo);
					xiaoshiInsertGroup();
					Ext.MessageBox.alert('提示框','<nobr>新增成功</nobr>');
				}else{
					document.getElementById("insertGroupName").value = '';
				}
			}
		}
		
		var re_groupname = /^[\w\u4E00-\u9FA5]{1,25}$/;
		function yanzhenggroupName(groupName){//验证组名称
			if(groupName == '' || groupName == null){
				Ext.MessageBox.alert('提示框','<nobr>组名不能为空</nobr>');
				return 'error';
			}
			if(groupName == '所有联系人' || groupName == '我的联系人'){
				Ext.MessageBox.alert('提示框','<nobr>组名\"'+groupName+'\"是系统保留的联系人组名，不允许使用该组名</nobr>');
				return 'error';
			}
			if(fu!=null && typeof(fu) !='undefined')
			{
				for(var a=0;a<fu.length;a=a+3){
					if(fu[a+1] == groupName){
						Ext.MessageBox.alert('提示框','<nobr>小组名已经存在</nobr>');
						return 'error';
					}
				}
			}
			
			if(groupName.length>25){  //中文，字母，数字，下划线
				Ext.MessageBox.alert('提示框','<nobr>新建组名不能超过25个字</nobr>');
				return 'error';
			}
			if(!re_groupname.test(groupName)){  //中文，字母，数字，下划线
				Ext.MessageBox.alert('提示框','<nobr>新建小组名含有非法字符</nobr>');
				return 'error';
			}
		}
		
		function returnGroupCaoZuo(str){//更新及新增组后的返回操作，重新更新组列表
			if(str == 'ok'){
				AddressListGroupBo.getGroup(<%=user.getUser_id() %>,<%=moduleType %>,Group);
			}
		}
		
		function xianshiUpdateGroup(){//显示更新组层
			if(fu!=''){
				if(fu.indexOf('我的联系人')!=-1 && fu.length<3){
					Ext.MessageBox.alert('提示框','<nobr>当前无可修改组</nobr>');
				}else{
					document.getElementById("updateGroupIndexDiv").style.top = document.body.clientHeight/6;
					document.getElementById("updateGroupIndexDiv").style.left = document.body.clientWidth/8;
					document.getElementById("blackdiv").style.display = "block";
					document.getElementById("updateGroupIndexDiv").style.display = "block";
					updateGroupName();
				}
			}else{
				Ext.MessageBox.alert('提示框','<nobr>当前无可修改组</nobr>');
			}
		}
		
		function xiaoshiUpdateGroup(){//消失更新组层
			document.getElementById("updateGroupIndexDiv").style.display = "none";
			document.getElementById("blackdiv").style.display = "none";
			document.getElementById("newGroupName").value = '';
			document.getElementById("newGroupNo").value = '';
		}
		
		function updateGroupName(){//向更新组层内添加组选项
			var updateGroup = '<table width="100%" class="researchtab"><tr>';
			var i = 0;
			for(var a=0;a<fu.length;a=a+3){
				if(fu[a+1] == '所有联系人' || fu[a+1] == '我的联系人'){
					continue;
				}else{
					if(fu[a+1].length>=10){
						updateGroup += '<td width="30%"><input name="groupidradio" type="radio" alt="'+fu[a+1]+","+fu[a+2]+'" id="groupidradio" value="'+fu[a]+'" onclick="newGroupName(this)"/><a title=\"'+fu[a+1]+'\">'+fu[a+1].substring(0,10)+'</a></td>';
					}else{
						updateGroup += '<td width="30%"><input name="groupidradio" type="radio" alt="'+fu[a+1]+","+fu[a+2]+'" id="groupidradio" value="'+fu[a]+'" onclick="newGroupName(this)"/>'+fu[a+1]+'</td>';
					}
				}
				i++;
				if(i%3 == 0){
					updateGroup += '</tr><tr>';
				}else if(a == fu.length-1){
					updateGroup += '</tr>';
				}
			}
			var updateGroupDiv = document.getElementById("updateGroupDiv");
			updateGroupDiv.innerHTML = updateGroup;
		}
		
		function yanzhengUpdate(groupName){//验证组名称
			if(groupName == '' || groupName == null){
				Ext.MessageBox.alert('提示框','<nobr>组名不能为空</nobr>');
				return 'error';
			}
			if(groupName == '所有联系人' || groupName == '我的联系人'){
				Ext.MessageBox.alert('提示框','<nobr>组名\"'+groupName+'\"是系统保留的联系人组名，不允许使用该组名</nobr>');
				return 'error';
			}
			if(fu!=null && typeof(fu) !='undefined')
			{
				var kk = 0;
				for(var a=0;a<fu.length;a=a+3){
					if(fu[a+1] == groupName){
						if(kk==1){
							Ext.MessageBox.alert('提示框','<nobr>小组名已经存在</nobr>');
							return 'error';
						}
						kk=1;
					}
				}
			}
			
			if(groupName.length>25){  //中文，字母，数字，下划线
				Ext.MessageBox.alert('提示框','<nobr>新建组名不能超过25个字</nobr>');
				return 'error';
			}
			if(!re_groupname.test(groupName)){  //中文，字母，数字，下划线
				Ext.MessageBox.alert('提示框','<nobr>新建小组名含有非法字符</nobr>');
				return 'error';
			}
		}
		
		function updateGroup(){//点击更新组确定按钮
			var a = 0;
			var id = 0;
			if(document.all('groupidradio').length != null && document.all('groupidradio').length > 0){
				for(i=0;i<document.all('groupidradio').length;i++){
					if(document.all('groupidradio')[i].checked){
						a = 1;
						id = document.all('groupidradio')[i].value;
					}
				}
			}else{
				if(document.getElementById('groupidradio').checked){
					a = 1;
					id = document.getElementById('groupidradio').value;
				}
			}
			if(a == 0){Ext.MessageBox.alert('提示框','<nobr>请选择组</nobr>');return;}
			var groupName = document.getElementById("newGroupName").value;
			var groupNo = document.getElementById("newGroupNo").value;
			var i = yanzhengUpdate(groupName);
			if(i != 'error'){
				if(isNaN(groupNo) || groupNo==''){
					alert('排序请输入整数');
				}else{
					if(i != 'error'){
						AddressListGroupBo.updateGroup(id,groupName,<%=user.getUser_id() %>,<%=moduleType %>,groupNo,returnGroupCaoZuo);
						xiaoshiUpdateGroup();
						Ext.MessageBox.alert('提示框','<nobr>修改成功</nobr>');
					}
				}
			}
		}
		
		function newGroupName(str){//点击更新组中组前radio时，将组信息赋值到下面的input中
			document.getElementById('newGroupName').value = str.alt.split(',')[0];
			document.getElementById('newGroupNo').value = str.alt.split(',')[1];
		}
		
		
		function xianshiDeleteGroup(){
			if(fu!=''){
				if(fu.indexOf('我的联系人')!=-1 && fu.length<3){
					Ext.MessageBox.alert('提示框','<nobr>当前无可删除组</nobr>');
				}else{
					document.getElementById("deleteGroupIndexDiv").style.top = document.body.clientHeight/5;
					document.getElementById("deleteGroupIndexDiv").style.left = document.body.clientWidth/6;
					document.getElementById("blackdiv").style.display = "block";
					document.getElementById("deleteGroupIndexDiv").style.display = "block";
					deleteGroupName();
				}
			}else{
				Ext.MessageBox.alert('提示框','<nobr>当前无可删除组</nobr>');
			}
		}
		
		function xiaoshiDeleteGroup(){
			document.getElementById("deleteGroupIndexDiv").style.display = "none";
			document.getElementById("blackdiv").style.display = "none";
		}
		
		function deleteGroupName(){
			var deleteGroup = '<table width="100%" class="researchtab"><tr>';
			var i = 0;
			for(var a=0;a<fu.length;a=a+2){
				if(fu[a+1] == '所有联系人' || fu[a+1] == '我的联系人'){
					continue;
				}else{
					if(fu[a+1].length>=10){
						deleteGroup += '<td width="30%"><input name="groupidradio" type="radio" alt="'+fu[a+1]+'" id="groupidradio" value="'+fu[a]+'"/><a title=\"'+fu[a+1]+'\">'+fu[a+1].substring(0,10)+'</a></td>';
					}else{
						deleteGroup += '<td width="30%"><input name="groupidradio" type="radio" alt="'+fu[a+1]+'" id="groupidradio" value="'+fu[a]+'"/>'+fu[a+1]+'</td>';
					}
				}
				i++;
				if(i%3 == 0){
					deleteGroup += '</tr><tr>';
				}else if(a == fu.length-1){
					deleteGroup += '</tr>';
				}
			}
			var deleteGroupDiv = document.getElementById("deleteGroupDiv");
			deleteGroupDiv.innerHTML = deleteGroup;
		}
		
		var deleteGroupId = '';
		function deleteGroup(){
			var a = 0;
			var id = 0;
			for(i=0;i<document.all('groupidradio').length;i++){
				if(document.all('groupidradio')[i].checked){
					a = 1;
					id = document.all('groupidradio')[i].value;
					deleteGroupId = id;
					if(i == groupA-1){groupA = 0}
				}
			}
			if(document.getElementById('groupidradio').checked){
				a = 1;
				id = document.getElementById('groupidradio').value;
				deleteGroupId = id;
			}
			if(a == 0){Ext.MessageBox.alert('提示框','<nobr>请选择组</nobr>');return;}
			AddressListGroupBo.FirstDeleteGroup(id,firstDeleteGroup);
			xiaoshiDeleteGroup();
			Ext.MessageBox.alert('提示框','<nobr>删除成功</nobr>');
		}
		
		function firstDeleteGroup(str){
			if(str == "haveUser"){
				Ext.MessageBox.confirm('提示框', '您删除组的时候会一并删除组内的联系人，请确认是否继续操作？', function(btn){
					if(btn=='yes'){
						AddressListGroupBo.deleteGroup(deleteGroupId,returnDeleteGroupCaoZuo);
						deleteGroupId = '';
					}
				});
			}else if(str == "error"){
				Ext.MessageBox.confirm('提示框', '您删除的组内含有要发送给其它系统用户的联系人信息，请确认是否继续操作？', function(btn){
					if(btn=='yes'){
						AddressListGroupBo.deleteGroup(deleteGroupId,returnDeleteGroupCaoZuo);
						deleteGroupId = '';
					}
				});
			}else{
				returnDeleteGroupCaoZuo();
			}
		}
		
		function submitAddListUser(){
			if(document.addListUser.group_id.value!=''){
				window.location.href="";
				document.addListUser.submit();
			}else{
				Ext.MessageBox.alert('提示框','<nobr>请选择要新增联系人信息的组</nobr>');
				return false;
			}
		}
		
		function deleteListUser(id){
			Ext.MessageBox.confirm('提示框', '您是否要删除此联系人？', function(btn){
				if(btn=='yes'){
					shaodeng();
					first = 'delete';
					AddressListUserBo.FirstDelectAddressListUser(id,{
						callback:function(str) {
							if(str == "have"){
								Ext.MessageBox.confirm('提示框', '您所删除的联系人要发送给其它系统用户，请确认是否继续操作？', function(btn){
									if(btn=='yes'){
										shaodeng();
										AddressListUserBo.deleteAddressListUser(id,intpage,<%=moduleType %>,init);
									}
								});
								huifu();
							}else{
								shaodeng();
								AddressListUserBo.deleteAddressListUser(id,intpage,<%=moduleType %>,init);
							}
						}
					});
				}
			});
		}
		
		function returnDeleteGroupCaoZuo(){
			first = 'shi';
			AddressListUserPageBo.getFirstPage(<%=user.getUser_id() %>,<%=moduleType %>,pagenum,ListUser);
		}
		function shaodeng(){
			document.getElementById("shaodeng").style.top = document.body.clientHeight/3;
			document.getElementById("shaodeng").style.left = document.body.clientWidth/3;
			document.getElementById("shaodeng").style.display = "block";
			document.getElementById("blackdiv").style.display = "block";
		}
		
		function huifu(){
			document.getElementById("shaodeng").style.display = "none";
			document.getElementById("blackdiv").style.display = "none";
		}
	</script>
	<%-- 向上向下滑动--%>
	 <script type="text/JavaScript">
var sh;
preLeft=0; currentLeft=0; stopscroll=false; getlimit=0;preTop=0; currentTop=0;
function scrollLeft()
{
	var marquees = document.getElementById("divgroup");
	if(stopscroll==true) return;
	preLeft=marquees.scrollTop;
	marquees.scrollTop+=2;
	if(preLeft==marquees.scrollTop)
	{
		//marquees.scrollLeft=templayer.offsetWidth-marqueesWidth+1;
	}
}

function scrollRight()
{
	var marquees = document.getElementById("divgroup");
	if(stopscroll==true) return;

	preLeft=marquees.scrollTop;
	marquees.scrollTop-=2;
	if(preLeft==marquees.scrollTop)
	{
		if(!getlimit)
		{
			marquees.scrollLeft=templayer.offsetWidth*2;
			getlimit=marquees.scrollLeft;
		}
		marquees.scrollLeft-=1;
	}
}

function Left()
{
	stopscroll = false;
	sh = setInterval("scrollLeft()",30);
}

function Right()
{
	stopscroll = false;
	sh = setInterval("scrollRight()",30);
}

function StopScroll()
{
	stopscroll = true;
	clearInterval( sh );
}
</script>
<%-- 宽窄屏截字符 --%>
<script type="text/javascript">
	function retrunString(str,k,z){
		if(screen.width <= 1024){
			str = str.substring(0,z);
		}else{
			str = str.substring(0,k);
		}
		return str;
	}
	
	function ifsubmit(str,k,z){
		if(screen.width <= 1024){
			if(str.length > z)return false; else return true;
		}else{
			if(str.length > k)return false; else return true;
		}
	}
</script>
  </head>
  
  <body>
    <div id="right" style="z-index: 19;width: 99%">
      	<div id="menu" style="padding-top:4px;"><a id="windowOpen" style="display: none;">&nbsp;</a></div>
      <table width="100%" border="0" cellspacing="0" cellpadding="0" style="border-right:#CCCCCC solid 1px;">
          <tr>
            <td width="132px;" valign="top" align="left" height="100%">
              <div class="conren" style="height: 450px" id="conren">
                <div class="h"><table width="132px;" border="0" cellspacing="0" cellpadding="0">
                      <tr>
                        <td width="20%" align="center"><img src="<%=basePath%>images/zuicon.png"/></td>
                        <td align="left">联系人组<br/></td>
                      </tr>
                    </table>
                </div>
                <div id="zushang" class="zuxia" onmouseout=StopScroll() onmouseover=Right() style='cursor:pointer;display: none;'></div>
                  <table width="132px;" height="390px" border="0" cellspacing="0" cellpadding="0" id="grouptable">
                    <tr height="80%" valign="top">
                      <td>
                      	<div id="divgroup"></div>
                      	<DIV id=templayer style="LEFT: 0px; VISIBILITY: hidden; POSITION: absolute; TOP: 0px"></DIV>
                      </td>
                    </tr>
                </table>
                <div id="zuxia" class="zushang" onmouseout=StopScroll() onmouseover=Left() style='cursor:pointer;display: none;'></div>
              </div>
            </td>
            <td width="100%" valign="top" id="tdindex">
               <div id="divindex" class="contab" style="height: 98%;width: 99%">
              </div>
            </td>
          </tr>
      </table>
</div>
<%-- 下面为form
updateListUser -- 进入新增联系人
 --%>
<form action="<%=basePath %>tjsinfo/tjsoa/addresslist/toInsertAddressListUser.do" name="addListUser" method="post">
	<input type="hidden" name="group_id" id="group_id">
	<input type="hidden" name="moduleType" id="moduleType" value="<%=moduleType %>">
</form>
<%-- 下面为隐藏层
insertGroup -- 新增组显示层
blackdiv -- 弹出新层时，周围的阴影层
 --%>

<div id="blackdiv" class="black_overlays">
	<iframe style="width:100%;height:100%;filter:alpha(opacity=0);-moz-opacity:0"></iframe>
</div>

<div class="insertGroup" id="insertGroup">
	<table width="478" border="0" cellpadding="0" cellspacing="0" >
               <tr>
                 <td height="24" align="left" background="<%=basePath%>images/small_07.gif">
                 <table width="99%" border="0" cellspacing="0" cellpadding="0">
				     <tr>
				         <td width="6%" align="center" style="padding-top:3px;"><img src="images/icon_06.gif" /></td>
				         <td width="88%" style="color:#FFFFFF; font-weight:bold;padding-top:3px">新建组</td>
				         <td width="6%" valign="bottom">
							<div class="cha">
								<img src="<%=basePath%>images/cha.gif"
									onclick="javaScript:xiaoshiInsertGroup();"
											style="cursor: hand" />
							</div>
						</td>
				     </tr>
				</table>
                 </td>
               </tr>
                <tr>
                 <td height="109" class="zz">
                     <table width="90%" height="80%" border="0" cellspacing="0" cellpadding="0" class="researchtab">
                      <tr>
                        <td width="10%">&nbsp;&nbsp;</td>
                        <td width="20%" align="center">组名称：</td>
                        <td width="70%" align="left"><input name="insertGroupName" type="text" size="40" class="textinput"/></td>
                      </tr>
                      <tr>
                        <td width="10%">&nbsp;&nbsp;</td>
                        <td width="20%" align="center">组排序：</td>
                        <td width="70%" align="left"><input name="insertGroupNo" type="text" size="10" class="textinput" value="1"/></td>
                      </tr>
                       <tr>
                        <td colspan="3" style="border-top:1px #CFCFD1 solid" align="center"><a href="javaScript:insertGroup();"><img src="<%=basePath%>images/baocun.gif" /></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                        <a href="javaScript:xiaoshiInsertGroup();"><img src="<%=basePath%>images/qx.gif" /></a>
                        </td>
                       </tr>
                    </table>
                 </td>
               </tr>
             </table>
</div>
<div id="updateGroupIndexDiv" class="updateGroupIndexDiv">
    <table width="478" border="0" cellpadding="0" cellspacing="0" >
               <tr>
                 <td background="<%=basePath%>images/small_07.gif" height="24" align="left">
                 <table width="99%" border="0" cellspacing="0" cellpadding="0">
                      <tr>
                        <td width="8%" style="padding-left:15px; padding-top:3px;"><img src="<%=basePath%>images/icon_07.gif" /></td>
                        <td width="86%" style="color:#FFFFFF; font-weight:bold;padding-top:3px">修改联系人组</td>
                        <td width="6%" valign="bottom">
							<div class="cha">
								<img src="<%=basePath%>images/cha.gif"
									onclick="javaScript:xiaoshiUpdateGroup();"
											style="cursor: hand" />
							</div>
						</td>
                      </tr>
                    </table>
                 </td>
               </tr>
               <tr>
                 <td align="center" class="zz">
                     <table width="90%" height="180" border="0" cellspacing="0" cellpadding="0" >
                      <tr><td colspan="3" align="left">
                       <div id="updateGroupDiv">
                       </div>
                      </td>
                      </tr>
                      <tr>
                        <td width="20%">&nbsp;</td>
                        <td width="13%">新名称：</td>
                        <td width="67%" align="left"><input name="newGroupName" id="newGroupName" type="text" size="30" class="textinput"/></td>
                      </tr>
                      <tr>
                        <td width="10%">&nbsp;&nbsp;</td>
                        <td width="20%" align="center">组排序：</td>
                        <td width="70%" align="left"><input name="newGroupNo" type="text" size="10" class="textinput"/></td>
                      </tr>
                      <tr>
                        <td colspan="3">&nbsp;</td>
                      </tr>
                      <tr><td colspan="3" style="border-top:1px #CFCFD1 solid">&nbsp;</td></tr>
                      <tr>
                        <td colspan="3" align="center"><a href="javaScript:updateGroup();"><img src="<%=basePath%>images/xiugai.gif" /></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                        <a href="javaScript:xiaoshiUpdateGroup();"><img src="<%=basePath%>images/qx.gif" />
                        </td>
                      </tr>
                      <tr>
                        <td colspan="3">&nbsp;</td>
                     </tr>
                    </table>
</td>
</tr>
</table>
</div>

<div id="deleteGroupIndexDiv" class="deleteGroupIndexDiv">
    <table width="478" border="0" cellpadding="0" cellspacing="0" >
               <tr>
                 <td background="<%=basePath%>images/small_07.gif" height="24" align="left">
                 <table width="99%" border="0" cellspacing="0" cellpadding="0">
                      <tr>
                        <td width="8%" style="padding-left:15px; padding-top:3px;"><img src="<%=basePath%>images/icon_07.gif" /></td>
                        <td width="86%" style="color:#FFFFFF; font-weight:bold;padding-top:3px">删除联系人组</td>
                        <td width="6%" valign="bottom">
							<div class="cha">
								<img src="<%=basePath%>images/cha.gif"
									onclick="javaScript:xiaoshiDeleteGroup();"
											style="cursor: hand" />
							</div>
						</td>
                      </tr>
                    </table>
                 </td>
               </tr>
               <tr>
                 <td align="center" class="zz">
                     <table width="90%" height="180" border="0" cellspacing="0" cellpadding="0" >
                      <tr><td colspan="3" align="left">
                       <div id="deleteGroupDiv">
                       </div>
                      </td>
                      </tr>
                      <tr>
                        <td colspan="3">&nbsp;</td>
                      </tr>
                      <tr><td colspan="3" style="border-top:1px #CFCFD1 solid">&nbsp;</td></tr>
                      <tr>
                        <td colspan="3" align="center"><a href="javaScript:deleteGroup();"><img src="<%=basePath%>images/xiugai.gif" /></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                        <a href="javaScript:xiaoshiDeleteGroup();"><img src="<%=basePath%>images/qx.gif" />
                        </td>
                      </tr>
                      <tr>
                        <td colspan="3">&nbsp;</td>
                     </tr>
                    </table>
</td>
</tr>
</table>
</div>

<div class="insertGroup" id="jiazai">
	<table width="478" border="0" cellpadding="0" cellspacing="0" >
               <tr>
                 <td height="24" align="left">
                 <b>页面加载中,请稍候....</b>
                 </td>
               </tr>
             </table>
</div>
<div class="insertGroup" id="shaodeng">
	<table width="478" border="0" cellpadding="0" cellspacing="0" >
               <tr>
                 <td height="24" align="left">
                 <b>请求正在处理中,请稍候....</b>
                 </td>
               </tr>
             </table>
</div>
  </body>
</html>
